/**
 * 
 */
package com.hs.chd.dao.impl;

import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.hs.chd.dao.IDataDao;
import com.hs.core.dao.impl.BaseDao;
import com.hs.core.utils.PageParam;
import com.hs.core.utils.PageQuery;
import com.hs.core.utils.PageUtil;

/**
 * @author shl
 *
 * Dec 9, 2010
 */
 
public class DataDao extends BaseDao implements IDataDao{
	 
	public PageUtil getPageList(PageParam pageParam){
		PageQuery pq = new PageQuery(pageParam);
		Query query = null;
		Query countquery = null;
		query = this.getSession().createQuery(pageParam.getSearchSql());
		Map map =pageParam.getConditionMap(); 
		String sql = pageParam.getSearchSql().toLowerCase();
		int index = sql.indexOf("from");
		String sqlall = pageParam.getSearchSql();
		countquery = this.getSession().createQuery("select count(*) " + sqlall.substring(index)); 
 		PageUtil pu = pq.getPageUtil(query,countquery); 
		return pu;
	}

	 
	
}
